﻿using System;
using System.Windows.Forms;
using System.IO;
using System.Collections.Generic;

namespace SS.Ynote.Classic.Components
{
    public partial class FindInFiles : WeifenLuo.WinFormsUI.Docking.DockContent
    {
        public FindInFiles()
        {
            InitializeComponent();
            this.cmbsearchoptions.DataSource = Enum.GetValues(typeof(SearchOption));
            cmbsearchoptions.SelectedIndex = 1;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog f = new FolderBrowserDialog();
            f.ShowDialog();
            if (!string.IsNullOrEmpty(f.SelectedPath))
                txtdir.Text = f.SelectedPath;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox2.Clear();
            List<string> allsearch = new List<string>();
            new StringFinder().FindReferences(allsearch, txtdir.Text, txtstring.Text, "*.*", SearchOption.AllDirectories);

            if (allsearch.Count != 0)
                foreach (string item in allsearch)
                    textBox2.Text += item + "\r\n";
            else
                textBox2.Text = "Nothing Found";

            tabControl1.SelectedIndex = 1;
        }

    }
}
